<template>
    <div>
        <h1>显示</h1>
        <a href="/Add">新增</a>
        <input type="text" v-model="quer.name">
        <select v-model="quer.classid">
            <option value="0">请选择</option>
            <option v-for="a in xiala" :value="a.memberClassId">{{ a.memberName }}</option>
        </select>
        <input type="button" value="查询" @click="show">
        <table>
            <thead>
                <tr>
                    <td>id</td>
                    <td>用户姓名</td>
                    <td>性别</td>
                    <td>手机号</td>
                    <td>会员等级</td>
                    <td>消费金额</td>
                    <td>消费次数</td>
                    <td>可用积分</td>
                    <td>可用余额</td>
                    <td>状态</td>
                    <td>新增时间</td>
                    <td>操作</td>
                </tr>
            </thead>
            <tbody>
                <tr v-for="a in data">
                    <td>{{ a.id }}</td>
                    <td>{{ a.name }}</td>
                    <td>{{ a.sex?"男":"女" }}</td>
                    <td>{{ a.phone }}</td>
                    <td>{{ a.memberClassId }}</td>
                    <td>{{ a.price }}</td>
                    <td>{{ a.prices }}</td>
                    <td>{{ a.initd }}</td>
                    <td>{{ a.initds }}</td>
                    <td>{{ a.indele }}</td>
                    <td>{{ moment(a.createDates).format("YYYY-MM-DD HH-MM-SS") }}</td>
                    <td>
                        <input type="button" :value="a.indele?'启用':'禁用'" @click="qj(a.id)">
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import { ref,onMounted } from 'vue';
import axios from 'axios';
import moment from 'moment';

const quer=ref({
    name:'',
    classid:0
})

const qj=(val:any)=>{
    axios.get("https://localhost:7295/api/Member/Statee",{params:{id:val}}).then(res=>{
        if(res.data>0){
            alert("成功")
            show()
        }
        else{
            alert("失败")
        }
    })
}

onMounted(()=>{
    dd()
    show()
})

const xiala=ref([{
    "memberClassId": 0,
    "memberName": ""
}])
const dd=()=>{
    axios.get("https://localhost:7295/api/MemberClass/GetMemberClasses",{params:xiala.value}).then(res=>{
        xiala.value=res.data;
    })
}

const show=()=>{
    axios.get("https://localhost:7295/api/Member/GetMember",{params:quer.value}).then(res=>{
        data.value=res.data;
    })
}

const data=ref([{
    "id": 0,
    "name": "",
    "initds": 0,
    "initd": 0,
    "createDates": "",
    "indele": false,
    "memberClassId": 0,
    "prices": 0,
    "phone": "",
    "price": 0,
    "sex": false,
    "memberName": ""
}])
</script>

<style scoped>

</style>